package com.magicsoft.app.helper;

import java.text.Collator;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import java.util.Locale;

import com.magicsoft.app.entity.ContactPerson;


/**
 * 汉子排序
 * @author chengyun
 *
 */
public  class ChineseSort implements Comparator<ContactPerson> {
	/**
	 * 根据字典名字的首字母进行排序
	 * 
	 * @param 要排序的list
	 * @return 排序后的list
	 */
	public static List<ContactPerson> sort(List<ContactPerson> list) {
		ChineseSort comp = new ChineseSort();
		Collections.sort(list, comp);
		return list; // 返回排序后的列表
	}

	public int compare(ContactPerson dic1, ContactPerson dic2) {
		
		String dicName1 = dic1.getPinyin().toString();
		String dicName2 = dic2.getPinyin().toString();

		return Collator.getInstance(Locale.CHINESE).compare(dicName1,
				dicName2);
	}

}
